package com.itHsuSE.demo11;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.invoke.MethodHandles;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int v=sc.nextInt();
        int[] s=new int[n];
        int[][] V=new int[101][101];
        int[][] W=new int[101][101];
        for (int i = 0; i < n; i++) {
            s[i]=sc.nextInt();
            for (int j = 0; j < s[i]; j++) {
                V[i][j]=sc.nextInt();
                W[i][j]=sc.nextInt();
            }
        }
        int[][] dp=new int[n+1][v+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= v; j++) {
                dp[i][j]=dp[i-1][j];
                for (int k = 0; k < s[i-1]; k++) {
                    if(j>=W[i-1][k]){
                        dp[i][j]= Math.max(dp[i][j],dp[i-1][j-W[i-1][k]]+V[i-1][k]);
                    }
                }
            }
        }
        System.out.println(dp[n][v]);
    }
}

class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner() {
        try {
            final String USERDIR = System.getProperty("user.dir");
            String cname = MethodHandles.lookup().lookupClass().getCanonicalName().replace(".MyScanner", "");
            cname = cname.lastIndexOf('.') > 0 ? cname.substring(cname.lastIndexOf('.') + 1) : cname;
            final File fin = new File(USERDIR + "/io/c" + cname.substring(1, 5) + "/" + cname + ".in");
            br = new BufferedReader(new InputStreamReader(fin.exists() ? new FileInputStream(fin) : System.in));
        } catch (Exception e) {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    }

    public String next() {
        try {
            while (st == null || !st.hasMoreElements()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
